#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QCheckBox>
#include <QLineEdit>
#include <QLabel>
#include <QVector>
#include <QGridLayout>
#include <QCloseEvent>
#include "plot.h"
#include "qled.h"
#include "minIni.h"
#include "trajectory.h"

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

protected:
    void closeEvent(QCloseEvent *event);

private:
    Ui::MainWindow *ui;
    minIni *iniFile;
    bool plotStatus,targetStatus;
    Plot *plot;
    trajectory *target;
    QVector<QString> ledName;
    QVector<QString> paraName;
    QVector<QString> dataName;
    QVector<int>    ledValue;
    QVector<double> paraValue;
    QVector<double> dataValue;

    QGridLayout *gridLayoutPara;
    QLineEdit *lineEditPara;
    QLabel *labelPara;
    QGridLayout *gridLayoutLed;
    QLed *ledLed;
    QLabel *labelLed;
    QGridLayout *gridLayoutData;
    QLineEdit *lineEditData;
    QLabel *labelData;

    void setupMain(void);

signals:
    void sendtoPlot(QVector<double> &v);
    void sendtoTraget(double x,double y);

private slots:
    void OpenConfig();
    void SaveConfig();
    void SendData();
    void SendData(QByteArray &data);
    void SendTarget(QVector<pair<double,double>> &v);
    void RecvData(QByteArray &data);
    void PlotData();
    void PlotTarget();
    void PlotDataClose();
    void PlotTargetClose();
};

#endif // MAINWINDOW_H
